package com.huang.design.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class playProxy {

     public static<T> T getProxy(T t){
         T o = (T) Proxy.newProxyInstance(t.getClass().getClassLoader(),
                 t.getClass().getInterfaces(),
                 new InvocationHandler() {
                     @Override
                     public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                         System.out.println("代理逻辑。。。执行");
                        Object invoke = method.invoke(t, args);
                         return null;
                     }
                 });

         return (T) o;
      }
}
